package com.bdqn.service.impl;

import com.bdqn.mapper.HisRegistrationMapper;
import com.bdqn.mapper.SysDeptMapper;
import com.bdqn.pojo.HisRegistration;
import com.bdqn.service.HisRegistrationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HisRegistrationServiceImpl implements HisRegistrationService {
    @Autowired
    HisRegistrationMapper hisRegistrationMapper;
    @Autowired
    SysDeptMapper sysDeptMapper;

    @Override
    public List<HisRegistration> getHisRegistrationKS(int deptId) {
        return hisRegistrationMapper.getHisRegistrationKS(deptId);
    }

    @Override
    public List<HisRegistration> getHisRegistration() {
        return hisRegistrationMapper.getHisRegistration();
    }

    @Override
    public PageInfo<HisRegistration> getHisRegistrationFY(int pageNum, int pageSize, int deptId, String patientName, int schedulingType, int subsectionType, int registrationStatus) {
        PageHelper.startPage(pageNum,pageSize);
        List<HisRegistration> list=hisRegistrationMapper.getHisRegistrationTJ(deptId,patientName,schedulingType,subsectionType,registrationStatus);
        for (HisRegistration hisRegistration:list){
            hisRegistration.setSysDept(sysDeptMapper.getSysDeptID(hisRegistration.getDeptId()));
        }

        PageInfo<HisRegistration> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<HisRegistration> getHisRegistrationTJ(int deptId, String patientName, int schedulingType, int subsectionType, int registrationStatus) {
        return hisRegistrationMapper.getHisRegistrationTJ(deptId,patientName,schedulingType,subsectionType,registrationStatus);
    }

    @Override
    public int addHisRegistration(HisRegistration hisRegistration) {
        return hisRegistrationMapper.addHisRegistration(hisRegistration);
    }

    @Override
    public int setHisRegistrationDANGE(int regStatus, String regId) {
        return hisRegistrationMapper.setHisRegistrationDANGE(regStatus,regId);
    }
}
